quartz menu: add special items
authorRyan Lortie <desrt@desrt.ca>
Wed, 15 Jan 2014 05:30:12 +0000 (00:30 -0500)
committerRyan Lortie <desrt@desrt.ca>
Sat, 18 Jan 2014 03:37:04 +0000 (22:37 -0500)
Add support for the "Hide app", "Hide Others" and "Show All" special
items and for the "Services" submenu.

https://bugzilla.gnome.org/show_bug.cgi?id=720552

gtk/gtkapplication-quartz-menu.c

index 0282996aaf15729ff5e8cd19251abb141c5aaf11..60e13d0286f9613f870951371a68694f6c2e0f35 100644 (file)
@@ -139,7 +139,31 @@ icon_loaded (GObject      *object,
 
   if (self != nil)
     {
-      [self setTarget:self];
+      const gchar *special = gtk_menu_tracker_item_get_special (aTrackerItem);
+
+      if (special && g_str_equal (special, "hide-this"))
+        {
+          [self setAction:@selector(hide:)];
+          [self setTarget:NSApp];
+        }
+      else if (special && g_str_equal (special, "hide-others"))
+        {
+          [self setAction:@selector(hideOtherApplications:)];
+          [self setTarget:NSApp];
+        }
+      else if (special && g_str_equal (special, "show-all"))
+        {
+          [self setAction:@selector(unhideAllApplications:)];
+          [self setTarget:NSApp];
+        }
+      else if (special && g_str_equal (special, "services-submenu"))
+        {
+          [self setSubmenu:[[[NSMenu alloc] init] autorelease]];
+          [NSApp setServicesMenu:[self submenu]];
+          [self setTarget:self];
+        }
+      else
+        [self setTarget:self];
 
       trackerItem = g_object_ref (aTrackerItem);
       trackerItemChangedHandler = g_signal_connect (trackerItem, "notify", G_CALLBACK (tracker_item_changed), self);